option(WITH_NET "Build SmartLib with net support" ON)
option(WITH_THREAD "Build SmartLib with thread support" ON)

include (CheckFunctionExists)

if(WITH_THREAD)
    unset(HAVE_PTHREAD_TRYJOIN CACHE)
    set(CMAKE_REQUIRED_LIBRARIES pthread)
    check_function_exists(pthread_tryjoin_np HAVE_PTHREAD_TRYJOIN)
    if(NOT HAVE_PTHREAD_TRYJOIN)
        add_definitions(-DNO_PTHREAD_TRYJOIN)
    endif(NOT HAVE_PTHREAD_TRYJOIN)
endif(WITH_THREAD)

set(SOURCES File.cpp FormatString.cpp Log.cpp Semaphore.cpp SmartPtr.cpp SysLog.cpp SysUser.cpp Timer.cpp)
if(WITH_NET)
    set(SOURCES ${SOURCES} Net/Socket.cpp Net/SocketClient.cpp Net/SocketServer.cpp)
endif(WITH_NET)
if(WITH_THREAD)
    set(SOURCES ${SOURCES} Thread.cpp)
endif(WITH_THREAD)

add_library(Smart ${SOURCES})
install(TARGETS Smart DESTINATION lib)

set(LIB_VERSION "${SmartLib_VERSION_MAJOR}.${SmartLib_VERSION_MINOR}.${SmartLib_VERSION_PATCH}")

set_target_properties(Smart PROPERTIES DEBUG_POSTFIX "d")
set_target_properties(Smart PROPERTIES VERSION ${LIB_VERSION})
